#ifndef TOP_DOWN_VIEW_HEADER
#define TOP_DOWN_VIEW_HEADER

/*
	TODO:
		Add a function which allows loading of avatar images 
			via SDL_Surface *'s.
*/
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <stdlib.h>

extern int TileWidth, TileHeight, AreaWidth, AreaHeight, MapHeight, MapWidth;
extern int AvatarX, AvatarY;

/* The interface functions: */

/* 
	This function must be callled before any other function, or it will
	probably cause a segmentation fault
	
	Param `Width':
		The width of the area that the TopDownView will control
	Param `Height':
		The height of the area that the TopDownView will control
	Param `Display':
		The area that the TopDownView will control
	
	Return:
		This function will return -1 if a failure, else 0
*/
int TDV_InitTopDownView(int Width, int Height, SDL_Surface *Display);
/* 
	This function sets a tile to an image 
	Param `Reference':
		The number that will reference that specific tile in the map
	Param `Filename':
		The filename that will be passed to the image handling function
	
	Return:
		This function will return the reference if everything went fine, 
		else it will return -1 and it can be handled accordingly
	
	Note:
		If the tile with reference `Reference' already exists, then it will be overwritten
*/
int TDV_SetTileFromFile(int Reference, char *Filename);
/*
	This function sets a tile to a surface
	Param `Reference':
		The number that will reference that specific tile in the map
	Param `Surface':
		The surface that the tile will be using 

	Return:	
		This function will return -1 on error, else Reference

	Note:
		If the tile with reference `Reference' already exists, it will be overwritten
*/
int SetTileFromSurface(int Reference, SDL_Surface *Surface);
/*
	TODO:
		Document this function
*/
int TDV_SetAvatarImage(SDL_Surface *Image);

/* Setters, pretty self explanatory */
void TDV_SetMap(int *Map);
void TDV_SetTileWidth(int Width);
void TDV_SetTileHeight(int Height);
void TDV_SetTileDimensions(int Width, int Height);
void TDV_ChangeAreaWidth(int Width);
void TDV_ChangeAreaHeight(int Height);
void TDV_ChangeAreaDimensions(int Width, int Height);
void TDV_SetAvatarX(int X);
void TDV_SetAvatarY(int Y);
void TDV_SetAvatarPosition(int X, int Y);
void TDV_SetMapWidth(int Width);
void TDV_SetMapHeight(int Height);
void TDV_SetMapDimensions(int Width, int Height);
/* Getters, also quite explanatory */
int TDV_GetTileWidth();
int TDV_GetTileHeight();
int TDV_GetAreaWidth();
int TDV_GetAreaHeight();
int TDV_GetAvatarX();
int TDV_GetAvatarY();
int TDV_GetMapWidth();
int TDV_GetMapHeight();
/*
	This function plots all of the viewable tiles onto the area allocated 
	Note:
		The changes will not be presented to the user until the application calls SDL_Flip(); on the screen
*/
void TDV_DrawToArea();
void TDV_DrawAvatar();
/* The internal functions:*/
SDL_Surface *TDV_I_GetTileAt(int X, int Y);

#endif
